home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / contrib / dom.php < prev    next >
PHP Script  |  2006-05-04  |  1KB  |  42 lines

  1. <?php
  2.  
  3.     $dom = new DOMDocument('1.0', 'iso-8859-1');
  4.  
  5.     $root = $dom->createElement('cds');
  6.     $dom->appendChild($root);
  7.  
  8.     mysql_connect("localhost","root","");
  9.     mysql_select_db("cdcol");
  10.  
  11.     $result=mysql_query("SELECT id,titel,interpret,jahr FROM cds ORDER BY interpret;");
  12.     
  13.     while( $row=mysql_fetch_array($result) )
  14.     {
  15.         $cd = $dom->createElement('cd');
  16.         $cd->setAttribute('id', $row['id']);
  17.  
  18.         $titel = $dom->createElement('titel');
  19.         $titel->appendChild($dom->createTextNode($row['titel']));
  20.         $cd->appendChild($titel);
  21.  
  22.         $interpret = $dom->createElement('interpret');
  23.         $interpret->appendChild($dom->createTextNode($row['interpret']));
  24.         $cd->appendChild($interpret);
  25.  
  26.         $jahr = $dom->createElement('jahr');
  27.         $jahr->appendChild($dom->createTextNode($row['jahr']));
  28.         $cd->appendChild($jahr);
  29.  
  30.         $root->appendChild($cd);
  31.     }
  32.  
  33.     header("Content-Type: text/xml;");
  34.     $xml="<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?> 
  35. <rss version=\"2.0\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:admin=\"http://webns.net/mvcb/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">
  36. <channel>
  37. ";
  38. echo $xml;
  39. print $dom->saveXML();
  40. echo "</channel></rss>";
  41. ?>
  42.